<!-- #INCLUDE Virtual="/lib.asp" -->
<!-- #INCLUDE Virtual="/lib_gen.asp" -->

<%
dim pageInhoud, path, folder
dim titel, page, rs, sql, rssImage

page = request.querystring("thispage")
if page <> "" then page = cstr(cdbl(page))

if request("preview") = "yes" then
	titel = request("titel")
	if titel="" then titel = request("folder")
else
	sql = "select * from vwcontent where id=" & page
	set rs = tmpConnection.execute(sql)
	titel = rs("titel")
end if

'params: folder
folder = request("folder")
path = server.mappath(".\..\..\images\album\" & folder)

if (request("sec") = "") then
	duration = 7
else
	duration = request("sec")
end if

pageInhoud = path & "<br>"

dim oFs, oFolder, oFile, nFiles
nFiles = 0
set oFs = Server.CreateObject("Scripting.FileSystemObject")
If oFs.FolderExists(path) Then
    Set oFolder = oFs.GetFolder(path)
    For Each oFile In oFolder.Files
		pageInhoud = ""
		if rssImage <> "" then rssImage = rssImage & ", "
		rssImage = rssImage & "'../../images/album/" & folder & "/" & server.htmlEncode(oFile.Name) & "'" & vbcrlf
		nFiles = nFiles + 1
    Next
End If
rssImage = "var afb = [" & rssImage & "];" & vbcrlf

pageInhoud = "<script>" & vbcrlf
pageInhoud = pageInhoud & rssImage & vbcrlf

pageInhoud = pageInhoud & "var bgCounter = -1;"& vbcrlf
pageInhoud = pageInhoud & "var bgCache = new Array();"& vbcrlf
pageInhoud = pageInhoud & "for (var t=0; t<afb.length; t++) {"& vbcrlf
pageInhoud = pageInhoud & "	bgCache[t] = new Image();"& vbcrlf
pageInhoud = pageInhoud & "	bgCache[t].src = afb[t];"& vbcrlf
pageInhoud = pageInhoud & "}"& vbcrlf
pageInhoud = pageInhoud & vbcrlf
pageInhoud = pageInhoud & "function changeBackground() {"& vbcrlf
pageInhoud = pageInhoud & "		hidePage();"& vbcrlf
pageInhoud = pageInhoud & "	if (bgCounter+1 >= afb.length) {"& vbcrlf
pageInhoud = pageInhoud & "		nextpage();"& vbcrlf
pageInhoud = pageInhoud & "	} else {"& vbcrlf
pageInhoud = pageInhoud & "		bgCounter = bgCounter+1;"& vbcrlf
pageInhoud = pageInhoud & "	}"& vbcrlf
pageInhoud = pageInhoud & "       $('body').attr('background', afb[bgCounter]);"& vbcrlf
pageInhoud = pageInhoud & "		  showPage();"& vbcrlf
pageInhoud = pageInhoud & "       resetCounter(7);"& vbcrlf
pageInhoud = pageInhoud & "       setTimeout(changeBackground, 7000);"& vbcrlf
pageInhoud = pageInhoud & "}"& vbcrlf
pageInhoud = pageInhoud & "changeBackground();"& vbcrlf
pageInhoud = pageInhoud & "startPulse()"& vbcrlf
pageInhoud = pageInhoud & "</script>" & vbcrlf
pageInhoud = pageInhoud & "<span id='albumtitel'>" & niceTitel(titel) & "</span><span id='counter' class='underline'>&nbsp;</span>"

call generatePageEx(request("preview"), request.querystring("nextpage"), "", "", rssImageAttr, pageInhoud, "", nFiles*duration + 30)

%>